<!--手机号注册-->
<div class="login">
    <form method="post" action="<?=Yii::$app->urlManager->createUrl(['/user/register','phone'=>true]);?>">
      <dl>
          <dt><p class="p1">二狐账号手机注册</p></dt>
          <dd>
             <div class="text_ico phone_num"></div>
             <div class="metext"><input type="text" class="user_tx" name="username" id="username" placeholder="请输入手机号码"/></div>
          </dd>
          <dd>
             <div class="text_ico code_ico"></div>
             <div class="metext"><input type="text" class="user_tx" name="captcha" id="captcha" placeholder="请输入验证码"/></div>
             <span onclick="sendSms()" id="getMobileCaptcha">发送验证码</span>

          </dd>
          <dd>
             <div class="text_ico password"></div>
             <div class="metext"><input type="password" class="user_tx" name="password" placeholder="请输入密码"/></div>
          </dd>
          <dt>
             <p class="p3"><input type="checkbox" value="1" name="is_agree" class="mycheck">同意<span>《二狐游戏服务协议》</span></p>
          </dt>
          <dt>
             <a href="#" class="a2">返回</a>
             <input type="hidden" name="_csrf" id="_csrf" value="<?=\Yii::$app->request->csrfToken; ?>" />
             <input type="submit" class="login_bt" value="注册" />
          </dt>
      </dl>
    </form>
  </div>

<?php $this->beginBlock('script'); ?>
<script type="text/javascript">
function sendSms(){
	var mobile = $('#username').val();
    $('#captcha').val('');
//     if($('#getMobileCaptcha').attr('disabled') ){
// 		return false;
// 	}
    //判断手机号
    if(mobile=="" || typeof(mobile) == "undefined"){
        alert("手机号码不能为空");
        $('#username').focus();
        return false;
    }
    //开始发送短信
    var csrfToken = $('meta[name="csrf-token"]').attr("content");
    $.ajax({
        type:"POST",
        url:"<?=Yii::$app->urlManager->createUrl('/captcha/send-sms');?>",
        data : { _csrf:csrfToken, mobile: mobile },
        dataType:"json",
        success:function(data){
            //$('#getMobileCaptcha').attr("disabled",false);
            $('#getMobileCaptcha').val("获取验证码");
            if(data){
            	if(data.send =="1"){
               	   alert('短信发送成功');
                } else {
               	   alert(data.info);
              	}
            }
        },
        error:function(data){
            alert(data.message);
        }
   });
}
</script>
<?php $this->endBlock('script'); ?>